From 6f07d5e761f2c1d18825f73033ab7d095ea2c70d Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Sun, 1 Feb 2015 12:08:04 +0100 Subject: [PATCH] x11: Detect libinput touchpads These aren't reported as XIDependentTouch devices, so make it poke a property that's specific to touchpads managed by the libinput driver. --- gdk/x11/gdkdevicemanager-xi2.c | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/gdk/x11/gdkdevicemanager-xi2.c b/gdk/x11/gdkdevicemanager-xi2.c index b0f3138037..50c1a00711 100644 --- a/gdk/x11/gdkdevicemanager-xi2.c +++ b/gdk/x11/gdkdevicemanager-xi2.c @@ -334,6 +334,32 @@ get_device_ids (GdkDisplay *display, return TRUE; } +static gboolean +is_touchpad_device (GdkDisplay *display, + XIDeviceInfo *info) +{ + gulong nitems, bytes_after; + guint32 *data; + int rc, format; + Atom type; + + gdk_x11_display_error_trap_push (display); + + rc = XIGetProperty (GDK_DISPLAY_XDISPLAY (display), + info->deviceid, + gdk_x11_get_xatom_by_name_for_display (display, "libinput Tapping Enabled"), + 0, 1, False, XA_INTEGER, &type, &format, &nitems, &bytes_after, + (guchar **) &data); + gdk_x11_display_error_trap_pop_ignored (display); + + if (rc != Success || type != XA_INTEGER || format != 8 || nitems != 1) + return FALSE; + + XFree (data); + + return TRUE; +} + static GdkDevice * create_device (GdkDeviceManager *device_manager, GdkDisplay *display, @@ -349,6 +375,8 @@ create_device (GdkDeviceManager *device_manager, if (dev->use == XIMasterKeyboard || dev->use == XISlaveKeyboard) input_source = GDK_SOURCE_KEYBOARD; + else if (is_touchpad_device (display, dev)) + input_source = GDK_SOURCE_TOUCHPAD; else if (dev->use == XISlavePointer && is_touch_device (dev->classes, dev->num_classes, &touch_source, &num_touches)) input_source = touch_source; -- 2.30.2